home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / GTCLR.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  896 b   |  33 lines

  1. #include <stdio.h>
  2. #include <graphics.h>
  3.  
  4. main()
  5. {
  6.    int graphdriver = DETECT, graphmode;
  7.    int oldcolor;
  8.    int y = 60;
  9.    char buffer[80];
  10.  
  11. /* Initialize the graphics system */
  12.    initgraph(&graphdriver, &graphmode, "c:\\turboc");
  13.    outtextxy(10, 20, "Demonstrating getcolor");
  14. /* Get current color */
  15.    oldcolor = getcolor();
  16.    sprintf(buffer,"Current color: %d", oldcolor);
  17.    outtextxy(10, 40, buffer);
  18.    moveto(0,y);
  19.    lineto(500,y);
  20.    y += 40;
  21. /* Select a new color and verify by calling getcolor */
  22.    setcolor(RED);
  23.    sprintf(buffer,"New color: %d (should be 4)", getcolor());
  24.    outtextxy(10, y-20, buffer);
  25.    moveto(0,y);
  26.    lineto(500,y);
  27. /* Restore previous color */
  28.    setcolor(oldcolor);
  29. /* Give user a chance to see the result */
  30.    outtextxy(10, y+60, "Hit any key to exit:");
  31.    getch();
  32.    closegraph();  /* Close graphics system */
  33. }